import configs
from .speech_synthesis_backend.speech_synthesis import Сommunication
from .speech_synthesis_backend.speech_synthesis_wrapper import Сommunication_wrapper
from template.singleton import Singleton
import os


class Class_control_messages(Singleton):
    def set_wrap_decoder(self, obj_wrapper_calls_fun) -> None:
        self.obj_communication = Сommunication()
        self.obj_communication.settings()
        self.obj_communication_wrapper = Сommunication_wrapper(
            self.obj_communication, obj_wrapper_calls_fun
        )

    def message(self, mess):
        self.obj_communication.message(mess)

    def notifications(self, mess):
        self.obj_communication.notifications(mess)

    def man_question(self) -> None:
        # mess = f"<p><h1>{config.speech_recognition_str_api}</h1></p>"
        self.obj_communication._print_message(
            f"Вы сказали: {configs.speech_recognition_str_api}\n"
        )

    def message_typle(self, mess_typle):
        self.obj_communication_wrapper.message_typle(mess_typle)

    def messege_menu(self, var_out_stream: str):
        self.obj_communication.messege_menu(var_out_stream)

    def mute_out(self):
        if self.obj_communication.__menu_list:
            self.obj_communication.__menu_list = []
        else:
            self.obj_communication.__menu_list = configs.default_modul

    def turning_on_message(self, message, level_message=0) -> None:
        if configs.turning_message:
            self.obj_communication.message(message)
        elif level_message == 1:
            self.obj_communication.message(message)
        else:
            pass
